package com.simple.study.filter;

/**
 * @ClassName UrlFilter
 * @Author SimpleTree
 **/
public class UrlFilter {
    //所有需要传递令牌的地址
    public static String filterPath = "/oauth/login,/oauth/tologin,/test,/loginNoOAuth," +
            "/rights,/menus,/roles,/roles/list," +
            "/users/**," +
            "/roles/**," +
            "/categories/**," +
            "/goods/**," +
            "/orders/**," +
            "/reports/**";

    public static boolean hasAuthorize(String url) {
        String[] split = filterPath.replace("/**", "").split(",");

        for (String value : split) {
            if (url.startsWith(value)) {
                //当前访问地址需要传递令牌
                return true;
            }
        }
        //当前访问地址不需要传递令牌
        return false;
    }
}
